package com.shujia.day13;

import java.util.Comparator;
import java.util.Optional;
import java.util.Scanner;
import java.util.TreeSet;

public class HScannerInput {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        TreeSet<Integer> integers = new TreeSet<>();

        while (true){
            System.out.println("请输入数字：");
            if (scanner.hasNextInt()) {
                int num = scanner.nextInt();
                integers.add(num);
                if (num == 0){
                    break;
                }
            }
        }

        Optional<Integer> max = integers.stream().max(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1 - o2;
            }
        });

        Integer integer = max.get();
        System.out.println(integer);


    }
}
